package entities;


import play.db.jpa.JPA;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: eagami
 * Date: 01/12/13
 * Time: 00:33
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name="Message")
@SequenceGenerator(sequenceName="Message_sequence" ,name="Message_sequence")
public class Message implements Serializable{


    private Long id;

    private Date date;

    private String text;

    private Boolean isNew;

    public Message(){}

    public Message(Date date, String text, Boolean aNew) {
        this.date = date;
        this.text = text;
        isNew = aNew;
    }

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="Message_sequence")
    @Column(name = "id")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name="date",unique=false,length=20,nullable=true)
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Column(name="text",unique=false,length=100,nullable=false)
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Column(name="isNew",unique=false,nullable=false)
    public Boolean getIsNew() {
        return isNew;
    }

    public void setIsNew(Boolean isNew) {
        this.isNew = isNew;
    }

    public Message save(){
        return JPA.em().merge(this);
    }
}
